﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AffinityORMLibrary.DataTypes;
using AffinityORMLibrary.DataLayer.Action;
using AffinityORMLibrary.DataLayer.Assembler;
using AffinityORMLibrary.DataLayer.Factory;
using AffinityORMLibrary.DataLayer.Utility;
using System.Configuration;

namespace AffinityORMLibrary.DataLayer.Factory
{
    class SysTableInfoFactory : Factory.FactoryBase<SysTableInfo>
    {
        public SysTableInfoFactory(ConnectionStringSettings connectionString) : base(connectionString)
        {

        }

        public List<SysTableInfo> GetSysTableInfo()
        {
            List<SysTableInfo> result;
            ISelectionAction action = new GetSysTableInfo();
            SysTableInfo domain = new SysTableInfo();
            domain.SetCriteria(typeof(SysTableInfo).GetProperty("TABLE_TYPE"), "BASE TABLE", SelectionCriteriaComparer.Equals);
            IAssembler<SysTableInfo> assembler = new SysTableInfoAssembler();

            try
            {
                result = this.Find(domain, assembler, action);
            }
            catch
            {
                result = new List<SysTableInfo>();
            }

            return result;
        }
    }
}
